package com.lxq.test2109.main01;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n,max,min,prev,next;
        Scanner sc = new Scanner(System.in);

        n=sc.nextInt();
        prev = sc.nextInt();
        max = min = prev;
        for (int i=1 ; i<n ;i++){
            next = sc.nextInt();
            if (prev == next){
                max = max + next;
                min = min + 0;
            }
            if (prev < next){
                max = max + next;
                min = min + next;
            }
            prev = next;
        }
        System.out.println(max);
        System.out.println(min);

    }
}
